<?php
use yii\helpers\Html;
use backend\modules\statistics\assets\EchartsAsset;
EchartsAsset::register($this);
use yii\bootstrap\BootstrapAsset;
BootstrapAsset::register($this);
$this->title = '订单统计';
?>


<style>
    .row{
        margin-right: 0;
        margin-left: 0;
    }
</style>

<section class="wrapper site-min-height">
    <!-- page start-->
    <section class="panel">


        <div class="row" style="margin-top:30px;">
            <div class="col-md-12">
                <div id="zhexian" style="height: 500px;width: 90%;"></div>
            </div>
            <div class="col-md-6">
                <div id="disease" style="height: 600px;width: 100%;"></div>
            </div>
        </div>


    </section>
</section>


<script>
    <?php $this->beginBlock('zhexian') ?>

    var base = +new Date(2017, 4, 1);
    var oneDay = 24 * 3600 * 1000;
    var date = [];
    var data = <?= $orders ?>;
    for (var i = 1; i < data.length; i++) {
        if(i == 1){
            var now = new Date(base);
        }else{
            var now = new Date(base += oneDay);
        }

        date.push([now.getFullYear(), now.getMonth() + 1, now.getDate()].join('-'));
    }

    var option = {
        title: {
            text: ''
        },
        tooltip : {
            trigger: 'axis',
            axisPointer: {
                type: 'cross',
                label: {
                    backgroundColor: '#6a7985'
                }
            }
        },
        legend: {
            data:['猪肉订单','认养订单','农家乐订单']
        },
        toolbox: {
            feature: {
                saveAsImage: {}
            }
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis : [
            {
                type : 'category',
                boundaryGap : false,
                data : date
            }
        ],
        yAxis : [
            {
                type : 'value'
            }
        ],
        series : [
            {
                name:'猪肉订单',
                type:'line',
                stack: '总量',
                areaStyle: {normal: {}},
                data:<?= $orders ?>
            },
            {
                name:'认养订单',
                type:'line',
                stack: '总量',
                areaStyle: {normal: {}},
                data:<?= $rasing ?>
            },
            {
                name:'农家乐订单',
                type:'line',
                stack: '总量',
                areaStyle: {normal: {}},
                data:<?= $house ?>
            }
        ]
    };

    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('zhexian'));
    myChart.setOption(option);


    <?php $this->endBlock('zhexian') ?>
    <?php $this->registerJs($this->blocks['zhexian'],\yii\web\View::POS_END) ?>
</script>
